package com.ilop.siteraudio.view.banner.layoutmanager;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.ilop.siteraudio.R;

public class WebBannerAdapter extends RecyclerView.Adapter<WebBannerAdapter.MzViewHolder> {

    private final Context context;

    private final int[] mImageList = new int[] {R.drawable.explain_1, R.drawable.explain_2, R.drawable.explain_3,
            R.drawable.explain_4, R.drawable.explain_5};
    private final int[] mTitleList = new int[] {R.string.instructions_guide_1, R.string.instructions_guide_2,
            R.string.instructions_guide_3, R.string.instructions_guide_4, R.string.instructions_guide_5};

    public WebBannerAdapter(Context context) {
        this.context = context;
    }

    @Override
    public MzViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MzViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_image, parent, false));
    }

    @Override
    public void onBindViewHolder(MzViewHolder holder, int position) {
        Glide.with(context).asGif().load(mImageList[position]).into(holder.imageView);
        holder.textView.setText(context.getString(mTitleList[position]));
    }

    @Override
    public int getItemCount() {
       return 5;
    }

    static class MzViewHolder extends RecyclerView.ViewHolder {
        TextView textView;
        ImageView imageView;

        MzViewHolder(View itemView) {
            super(itemView);
            textView = itemView.findViewById(R.id.messages);
            imageView = itemView.findViewById(R.id.image);
        }
    }
}
